package xyz.yuzegod.megawalls.timer;

import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import xyz.yuzegod.megawalls.game.Game;
import xyz.yuzegod.megawalls.game.GamePlayer;

public class CenterCheckTimer implements Runnable
{
    private Game game;
    
    public CenterCheckTimer(final Game game) {
        this.game = game;
    }
    
    @Override
    public void run() {
        for (final GamePlayer gamePlayer : GamePlayer.getOnlinePlayers()) {
            if (gamePlayer.isSpectator()) {
                continue;
            }
            if (this.game.getCenterArea().isInRegion(gamePlayer.getPlayer().getLocation())) {
                continue;
            }
            gamePlayer.sendTitle("", "§c设法到达中间以阻止饥饿！", 10, 20, 10);
            gamePlayer.sendMessage("§c§l设法到达中间以阻止饥饿！");
            gamePlayer.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, 100, 1));
        }
    }
}
